package com.lkd.config;

import org.springframework.format.Formatter;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

/**
 * @author brianxia jackson 修改
 * @version 1.0
 * @date 2022-07-26 11:03
 */
public class LocalDateFormatter implements Formatter<LocalDate> {

    private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

    @Override
    public LocalDate parse(String s, Locale locale) throws ParseException {
        return LocalDate.parse(s,dateTimeFormatter);
    }

    @Override
    public String print(LocalDate localDate, Locale locale) {
        return localDate.format(dateTimeFormatter);
    }
}
